package com.zazu.mycl.application.commands;

import java.io.File;

import com.zazu.mycl.application.AbstractTerminalCommand;
import com.zazu.mycl.application.CommandRunner;
import com.zazu.mycl.application.constants;

public class ListRootsCommand extends AbstractTerminalCommand {

	@Override
	public void run(String[] args, CommandRunner commandRunner,
			String commandLine, String outputFileName) {

		String myDir = commandRunner.getVariable(constants.CURRENT_DIRECTORY);
		
		this.commandRunner = commandRunner;
		
		this.commandRunner.SetLine("Getting root directories...");
		
		listRoots();
	}

	public void listRoots()
	{
		File[] files = File.listRoots();
		
		if(files.length != 0)
		{
				for(File file : files)
				{
					commandRunner.SetLine("\t"+getFileInd(file)+"\t"+file.getPath());
				}
		}
		else
		{
			commandRunner.SetLine("\t[None]");
		}
		
	}
	
	private String getFileInd(File f)
	{
		if(f.isDirectory())
		{
			return "  ACTIVE ->";
		}
		else
		{
			return "INACTIVE ->";
		}
	}
	
	@Override
	public void runSubCommand(String[] args, String commandLine) {
		// TODO Auto-generated method stub

	}

	public String getSignature() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean isThreadable() {
		// TODO Auto-generated method stub
		return isThreadable;
	}

	private boolean isThreadable = true;
	private CommandRunner commandRunner;
	
}
